﻿<!DOCTYPE html>
<!--隐患排查内容管理-->


<!-- 展开行列表，列相同合并，功能贼牛鼻 -->


<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
        <script src="/static/js/common.js"></script>

    <link href="../static/js/vue-treeselect/vue-treeselect.css" rel="stylesheet" />
    <script src="../static/js/vue-treeselect/vue-treeselect.js"></script>
    <style>
        .el-dialog__body {
            height: 100% !important;
        }

        .el-dialog.is-fullscreen {
            overflow: hidden !important;
        }

        .vue-treeselect__control {
            height: 100%;
            border: none;
            background: none;
        }

        .vue-treeselect__placeholder {
            top: -3px;
        }

        .vue-treeselect__single-value {
            top: -3px;
        }

        .demo-table-expand {
            font-size: 0;
        }

        .demo-table-expand label {
            width: 90px;
            color: #99a9bf;
        }

        .demo-table-expand .el-form-item {
            margin-right: 0;
            margin-bottom: 0 !important;
            width: 100%;
            padding-left: 45px;
        }

        .el-form-item__content span {
            line-height: 40px;
        }
    </style>
</head>

<body>
    
<div id="app" v-cloak>   

        <el-form label-position="right" ref="form" :inline="true" :model="formInline" class="demo-form-inline"
            style="margin-bottom: 15px;">

            <el-row>
                <el-col class="head-tool">
                    
<div class="new_title fl"><strong><img src="/static/images/icon1.png" />隐患排查内容管理列表</strong></div>

                    <span>
                        <btn :text="col.btnSelect" imgsrc="/static/images/search.png" linetype="3" @click="onSubmit">
                        </btn>
                        <btn :text="col.btnAdd" linetype="3" @click="UserInput('tj')"></btn>
                        <btn-uploadfile-list url="xxxx" linetype="3"></btn-uploadfile-list>
                        <btn-export-list url="xxxx" :forminline="this.formInline" linetype="3"></btn-export-list>
                        <btn :text="col.btnDelete" linetype="4" @click="onDelete"></btn>
                    </span>
                </el-col>
            </el-row>
            <el-row>

                <el-col :xs="12" :sm="8" :md="6" :lg="6" :xl="6">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input v-model="formInline.model.Unit" :placeholder="RisksManagement.RiskContent.Unit"
                                size="mini">
                                <template slot="prepend">
                                    {{RisksManagement.RiskContent.Unit+mark.m}}
                                </template>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>

                <el-col :xs="12" :sm="8" :md="6" :lg="6" :xl="6">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input v-model="formInline.model.Objective"
                                :placeholder="RisksManagement.RiskContent.Objective" size="mini">
                                <template slot="prepend">
                                    {{RisksManagement.RiskContent.Objective+mark.m}}
                                </template>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>

                <el-col :xs="12" :sm="8" :md="6" :lg="6" :xl="6">
                    <div class="elst-select-mini">
                        <el-form-item>

                            <el-input size="mini">
                                <template slot="prepend">
                                    {{RisksManagement.RiskContent.PersonInCharge+mark.m}}
                                </template>
                                <treeselect v-model="formInline.model.PersonInCharge" :options="PersonInCharge"
                                    :flat="true" :show-count="true" :disable-branch-nodes="true" slot="suffix"
                                    placeholder="请选择" style="line-height: 28px;" />
                                <!--<treeselect v-model="treeselected" :options="PersonInCharge" :flat="true"
                                            :show-count="true" :disable-branch-nodes="true" slot="suffix" placeholder="请选择"
                                            style="line-height: 28px;" />-->
                            </el-input>

                        </el-form-item>
                    </div>
                </el-col>
                <el-col :xs="12" :sm="8" :md="6" :lg="6" :xl="6">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input v-model="formInline.model.Participant"
                                :placeholder="RisksManagement.RiskContent.Participant" size="mini">
                                <template slot="prepend">
                                    {{RisksManagement.RiskContent.Participant+mark.m}}
                                </template>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :xs="12" :sm="8" :md="6" :lg="6" :xl="6">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input v-model="formInline.model.Content"
                                :placeholder="RisksManagement.RiskContent.Content" size="mini">
                                <template slot="prepend">
                                    {{RisksManagement.RiskContent.Content+mark.m}}
                                </template>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>


            </el-row>
        </el-form>


        <el-col :span="24">
            <el-table stripe ref="table" :data="ListItem.tableData" :height="ListItem.tableHeight" border
                @selection-change="handleSelectionChange" row-style="height:10px" style="width: 100%"
                :expand-row-keys="expands" row-key="id">
                <el-table-column type="selection" align="center" width="55">
                </el-table-column>
                <el-table-column type="expand">
                    <template slot-scope="props">
                        <el-table ref="subtable" :data="props.row.InputTable" border :span-method="objectSpanMethod">
                            <el-table-column prop="Project" :label="RisksManagement.RiskContent.Project">
                            </el-table-column>
                            <el-table-column prop="Region" :label="RisksManagement.RiskContent.Region"
                                :formatter="getDicValue">
                            </el-table-column>
                            <el-table-column prop="Remark" :label="RisksManagement.RiskContent.Remark">
                            </el-table-column>
                            <el-table-column prop="Standard.data" :label="RisksManagement.RiskContent.Standard">
                            </el-table-column>
                            <el-table-column prop="RiskLevel" :label="RisksManagement.RiskContent.RiskLevel">
                            </el-table-column>
                        </el-table>
                    </template>
                </el-table-column>

                <el-table-column type="index" :label="RisksManagement.RiskContent.id" :index="indexMethod" width="50"
                    show-overflow-tooltip="true"></el-table-column>
                <el-table-column prop="Unit" :label="RisksManagement.RiskContent.Unit" show-overflow-tooltip="true">
                </el-table-column>
                <el-table-column prop="Objective" :label="RisksManagement.RiskContent.Objective"
                    show-overflow-tooltip="true">
                </el-table-column>
                <el-table-column prop="PersonInCharge" :formatter="getDicValue" show-overflow-tooltip="true" width="150"
                    :label="RisksManagement.RiskContent.PersonInCharge">
                </el-table-column>
                <el-table-column prop="Participant" :formatter="getDicValue" show-overflow-tooltip="true" width="150"
                    :label="RisksManagement.RiskContent.Participant">
                </el-table-column>
                <el-table-column prop="Requirements" :label="RisksManagement.RiskContent.Requirements" min-width="150"
                    show-overflow-tooltip="true">
                </el-table-column>
                <el-table-column prop="Content" :label="RisksManagement.RiskContent.Content" min-width="150"
                    show-overflow-tooltip="true">
                </el-table-column>
                <el-table-column prop="StandardType" :label="RisksManagement.RiskContent.StandardType" min-width="150"
                    show-overflow-tooltip="true">
                </el-table-column>
                <el-table-column prop="InvestigationPost" :label="RisksManagement.RiskContent.InvestigationPost"
                    min-width="150" show-overflow-tooltip="true">
                </el-table-column>
                <el-table-column prop="DailyAndPlan" :label="RisksManagement.RiskContent.DailyAndPlan" min-width="150"
                    show-overflow-tooltip="true">
                </el-table-column>


                <el-table-column prop="FrequencyText" :label="RisksManagement.RiskContent.Frequency" min-width="150"
                    show-overflow-tooltip="true">
                </el-table-column>
                <el-table-column width="53" prop="update" :label="col.btnUpdate" fixed="right">
                    <template slot-scope="scope">
                        <button type="button" class="elst-bt-xg" @click=UserInput('xg',scope.row.id)>
                            <i class="el-icon-edit"></i>
                        </button>
                    </template>
                </el-table-column>
            </el-table>
            <el-row type="flex" justify="end">


                <el-pagination ref="page" @size-change="handleSizeChange" @current-change="handleCurrentChange"
                    :current-page="ListItem.currentPage" :page-sizes="ListItem.pagesizes" :page-size="ListItem.pagesize"
                    :layout="ListItem.layout" :total="ListItem.total">
                </el-pagination>

            </el-row>
        </el-col>
        <el-dialog title="隐患排查内容管理" :visible.sync="ListItem.dialogVisible" @close='closeDialog' width="80%" height="80%"
            top="10vh" fullscreen="true">
            <iframe ref="iframe" :src="ListItem.InputUrl" style="height:95%;width:100%" frameborder="0"></iframe>
        </el-dialog>
        <!--:fullscreen="true"-->
    </div>
    <script type="text/javascript">
        // var num=0;

        Vue.component('treeselect', VueTreeselect.Treeselect)
        app = new Vue({
            el: '#app',
            data: function () {
                return {
                    spanArr: [],
                    expands: [],
                    num: '0',
                    mydata: PersonInChargeTree,
                    defaultProps: {
                        children: 'children',
                        label: 'label'
                    },
                    Region: myTree,
                    //页面内数据初始化
                    ListItem: ListItem,
                    formInline: {
                        model: {
                            Unit: '',
                            Objective: '',
                            PersonInCharge: null,
                            Participant: '',
                            Content: ''
                        },
                        offset: 0,
                        limit: 10
                    },
                    PersonInCharge: [],
                }
            },
            created: function () {
                var currApp = this;
                window.onresize = function () {
                    currApp.ListItem.tableHeight = window.innerHeight -
                        currApp.$refs.table.$el.offsetTop - 60;
                    if (currApp.ListItem.tableHeight < 112) {
                        currApp.ListItem.tableHeight = 112;
                    }
                }
            },
            mounted: function () {
                var contactDot = 0;
                //初始化数据
                this.GetPageData(1);
                var mythis = this;
                //列表高度自适应
                tablehigh(this);
                this.PersonInCharge = fn(this.mydata, "0");
            },
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                //合并行方法
                getSpanArr: function (data, a) {
                    console.log(data)
                    //生成合并行数据组
                    this.spanArr.push([]);
                    var spanArr = this.spanArr[this.spanArr.length - 1];
                    //console.log('Begin', this.spanArr);
                    //初始化行号
                    var c = 0;
                    //ebugger;
                    //遍历数据
                    //this.ListItem.tableData.forEach(function (v, i) {
                    data.forEach(function (v, i) {
                        v.num = a;
                        //第一条数据固定
                        if (i === 0) {
                            spanArr.push(1);
                        }
                        else {
                            //如果当前数据跟上一条数据id相同，则合并行数据+1，并且填充0合并行
                            if (v.id === data[i - 1].id) {
                                spanArr[c] += 1;
                                spanArr.push(0);
                            }
                            else {
                                //如果不相同，则重置合并数量，且更改合并行数据组索引
                                spanArr.push(1);
                                c = i;

                            }
                        }
                    })
                    //console.log('End', this.spanArr);
                },

                objectSpanMethod: function (row, column, rowIndex, columnIndex) {
                    //声明列对象，行对象
                    var columnIndex = row.columnIndex, rowIndex = row.rowIndex
                    //判断需要合并的列
                    if (columnIndex === 0 || columnIndex === 1 || columnIndex === 2) {
                        //读取当前行的合并数量
                        var _row = this.spanArr[row.row.num][rowIndex];
                        //console.log('输出合并行序列',rowIndex, _row)
                        //如果当前行合并，则对应列为1，否则0（0为不显示）
                        var _col = _row > 0 ? 1 : 0;
                        return [_row, _col]
                    }
                },
                //表格序号连续化
                indexMethod: function (index) { return (this.ListItem.currentPage - 1) * this.ListItem.pagesize + index + 1; },
                getDicValue: function (row, column, cellValue, index) {
                    switch (column.property) {
                        case "Region":
                            return getTreeValue(this.Region, cellValue)
                            break;
                        case "RiskLevel":
                            return getDicValue('03', cellValue)
                            break;
                        default:
                    };
                    if (cellValue) {
                        if (typeof cellValue === 'string' || typeof cellValue === 'number') {
                            return getTreeValue(this.mydata, cellValue)
                        }
                        else {
                            var result = '';
                            for (var i = 0; i < cellValue.length; i++) {
                                result += getTreeValue(this.mydata, cellValue[i]) + ',';
                            }
                            result = result.substr(0, result.length - 1);
                            return result;
                        }
                    };
                },
                closeDialog: function () { closeDialog(this); },
                //删除方法
                onDelete: function () { onDelete(this, '/api/RiskContent/DeleteMuti'); },
                //列表选择触发
                handleSelectionChange: function (val) { handleSelectionChange(this, val); },
                //Dialog展示
                UserInput: function (val, id) {
                    //从弹窗修改为跳页
                    //var url = 'RiskContentInput.html';
                    //var href = '';
                    //if (val == 'tj') {
                    //    href = url + "?t=" + Date.parse(new Date());
                    //} else {
                    //    href = url + "?id=" + id + "&t=" + Date.parse(new Date());
                    //}
                    //location.href = href;

                    DialogShow(this, val, "RiskContentInput.html", id);
                },
                //获取分页数据
                GetPageData: function (currentIndex) {
                    var mythis = this;
                    mythis.formInline.offset = (currentIndex - 1) * mythis.ListItem.pagesize;
                    mythis.formInline.limit = mythis.ListItem.pagesize;
                    var currObj = mythis;
                    myAjax("post", mythis, '/api/RiskContent/GetList', mythis.formInline, function (response) {
                        console.log("response", response);
                        currObj.ListItem.tableData = response.data.pageData
                        currObj.ListItem.total = response.data.rowCount;
                        //debugger;
                        currObj.spanArr = [];
                        for (var i = 0; i < currObj.ListItem.tableData.length; i++) {
                            currObj.getSpanArr(currObj.ListItem.tableData[i].InputTable, i);
                        }
                    });
                    //GetPageData(this, currentIndex, '/api/RiskContent/GetList')
                },
                //查询方法
                onSubmit: function () { onSubmit(this); },
                //pagesize改变 触发方法
                handleSizeChange: function (val) { handleSizeChange(this, val); },
                //跳页触发方法
                handleCurrentChange: function (val) { handleCurrentChange(this, val); }
            }
        });

    </script>
</body>

</html>